<?php

declare(strict_types=1);
/**
 * Created by PhpStorm.
 * User: yangfan
 * Date: 2019/12/3
 * Time: 10:16 AM
 */

namespace App\Entity;

use App\Models\OrderRefund;

class OrderRefundEntity extends ABaseEntity
{
    public function __construct(OrderRefund $model)
    {
        $this->model = $model;
    }

    /**
     * @return OrderRefundEntity|null
     */
    public static function findByOrderId(int $orderId)
    {
        $orderRefund = OrderRefund::where('order_id', '=', $orderId)
            ->orderBy('id', 'desc')
            ->first();
        if ($orderRefund === null) {
            return null;
        }

        return new self($orderRefund);
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->model->id;
    }

    public function setOrderId(int $orderId)
    {
        $this->model->order_id = $orderId;
    }

    /**
     * @return int
     */
    public function getOrderId()
    {
        return $this->model->order_id;
    }

    public function setPaymentMethod(string $paymentMethod)
    {
        $this->model->payment_method = $paymentMethod;
    }

    public function getPaymentMethod(): string
    {
        return $this->model->payment_method;
    }

    public function setPaymentNo(string $paymentNo)
    {
        $this->model->payment_no = $paymentNo;
    }

    public function setRefundNo(string $refundNo)
    {
        $this->model->refund_no = $refundNo;
    }

    /**
     * @return string
     */
    public function getRefundNo()
    {
        return (string) $this->model->refund_no;
    }

    public function setOutRefundNo(string $outRefundNo)
    {
        $this->model->out_refund_no = $outRefundNo;
    }

    public function setTotalAmount($amount)
    {
        $this->model->total_amount = $amount;
    }

    /**
     * @return string
     */
    public function getTotalAmount()
    {
        return (string) $this->model->total_amount;
    }

    public function setRefundStatus(int $refundStatus)
    {
        $this->model->refund_status = $refundStatus;
    }

    /**
     * @return int
     */
    public function getRefundStatus()
    {
        return $this->model->refund_status;
    }

    /**
     * 退款时间
     */
    public function setRefundAt(string $refundAt)
    {
        $this->model->refund_at = $refundAt;
    }

    /**
     * 退款时间
     */
    public function getRefundAt(): string
    {
        return (string) $this->model->refund_at;
    }

    /**
     * 退款原因
     */
    public function setNote(string $note)
    {
        $this->model->note = $note;
    }

    /**
     * 退款原因
     *
     * @return string
     */
    public function getNote()
    {
        return $this->model->note;
    }

    /**
     * 管理员拒绝退款原因
     */
    public function setAdminNote(string $adminNote)
    {
        $this->model->admin_note = $adminNote;
    }

    /**
     * 获取管理员拒绝退款原因
     *
     * @return mixed
     */
    public function getAdminNote()
    {
        return $this->model->admin_note;
    }

    public function getVersion(): string
    {
        return (string) $this->model->version;
    }

    public function setVersion(string $version): void
    {
        $this->model->version = $version;
    }

    /**
     * @return string
     */
    public function getCreatedAt()
    {
        return $this->model->created_at;
    }

    public function getPreOrderState(): int
    {
        return $this->model->pre_order_state;
    }

    public function setPreOrderState(int $pre_order_state): void
    {
        $this->model->pre_order_state = $pre_order_state;
    }

    public function getType(): int
    {
        return $this->model->type;
    }

    public function setType(int $type): void
    {
        $this->model->type = $type;
    }
}
